package com.example.demo.study.opp;

public class TestAnimal {
    public static void main(String[] args) {
        Animal animal = new Animal();
        Animal animal1 = new Dog(); // 实际指向Dog对象
        Animal animal2 = new Cat(); // 实际指向Cat对象
        Dog dog = (Dog) animal1;
        Cat cat = (Cat) animal2;

    }

    public static void testInt(Animal animal){
        if(animal instanceof Dog){
            new Dog();
            animal.makeSound();
        }else {
            new Cat();
            animal.makeSound();
        }

    }
}
